package com.itheima.work1120;

import java.util.HashMap;
import java.util.Map;

public class Demo3 {
    public static void main(String[] args) {
        HashMap<Integer,String> map = new HashMap<>();
        map.put(1,"张三");
        map.put(2,"李四");
        map.put(3,"王五");
        System.out.println(map.size());
        //键找值遍历集合
        for (Integer key : map.keySet()) {
            String value = map.get(key);
            System.out.println("key:" + key + " value:" + value);
        }
        //键值对遍历集合
        for(Map.Entry<Integer,String> entry : map.entrySet()){
            Integer key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + "---->" + value);
        };
        System.out.println(map.get(1));
        System.out.println(map.get(10));
        System.out.println(map.containsKey(10));
        System.out.println(map.remove(1));
        System.out.println(map);

    }
}
